package my.action.article;
import java.util.ArrayList;

import javax.servlet.http.*;

import my.controller.*;
import my.db.DAO.ArticleDAO;
import my.db.DAO.AuthenticationDAO;
import my.db.DAO.AuthorDAO;
import my.db.DTO.ArticleDTO;
import my.db.DTO.AuthenticationDTO;
import my.db.DTO.AuthorDTO;
public class ArticleDeleteAction implements  Action{
	 public ActionForward execute(HttpServletRequest request,HttpServletResponse response) throws Exception{
		 	ArticleDAO dao=new ArticleDAO();
		   	ActionForward forward=new ActionForward();
		   	String name[]=request.getParameterValues("check_id");
			String select="";
		   	if(name !=null){
				 if(name.length==1){
					 select=name[0];
					}else{
						for( int i=0;i<name.length;i++){
							select+=name[i];
							if(i <name.length-1){
								select+=",";
							}
						}
					}	
					boolean result=true;
			   		try{   			
			   			result=dao.delete(select);
			   			if(result==true){
			   				forward.setRedirect(true);
			   				forward.setPath("./author_load.jsp");
			   			}
			  		}catch(Exception ex){
			  			System.out.println(ex);
			   		}
			 }else{
				 forward.setRedirect(true);
				 forward.setPath("./author_load.jsp");
			 }	   
	  		return forward;
		}  		
}